package main

import (
	"fmt"
	"sync"
)

func testWithPointerOnce() {
	fmt.Println("testWithPointerOnce")
}
func printTestWithPointerOnce(once *sync.Once) {
	once.Do(testWithPointerOnce)
}
func main() {
	var wg sync.WaitGroup
	var once sync.Once
	size := 10
	wg.Add(size)
	for i := 0; i < size; i++ {
		go func() {
			defer wg.Done()
			printTestWithPointerOnce(&once)
		}()
	}
	wg.Wait()
	fmt.Println("main end~~~")
}
